// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.linqingying.gitcode.pullrequest.ui.details.model.impl

import com.linqingying.gitcode.api.data.pullrequest.GCPullRequestRequestedReviewer
import com.linqingying.gitcode.pullrequest.data.service.GCPRRepositoryDataService
import com.linqingying.gitcode.pullrequest.ui.details.model.GCPRMetadataModel
import java.util.concurrent.CompletableFuture

abstract class GCPRMetadataModelBase(private val repositoryDataService: GCPRRepositoryDataService) : GCPRMetadataModel {

  override fun loadPotentialReviewers(): CompletableFuture<List<GCPullRequestRequestedReviewer>> {
    val author = getAuthor()
    return repositoryDataService.potentialReviewers.thenApply { reviewers ->
      reviewers.mapNotNull { if (it == author) null else it }
    }
  }

  override fun loadPotentialAssignees() = repositoryDataService.issuesAssignees
  override fun loadAssignableLabels() = repositoryDataService.labels
}
